﻿using FarmSmartSleep.Common.Domain.RaiseManagement;
using FarmSmartSleep.Common.Dtos;
using FarmSmartSleep.Common.Infrastructure;
using MediatR;

namespace FarmSmartSleep.Organ.API.Application.RaiseOnlyManagementCommands.EliminateCommands
{
    public class CauseSelectHandler : IRequestHandler<CauseSelectCommand, Result>
    {
        private readonly IBaseRepository<Culled> culledRep;

        public CauseSelectHandler(IBaseRepository<Culled> culledRep)
        {
            this.culledRep = culledRep;
        }


        /// <summary>
        /// 淘汰原因
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Result> Handle(CauseSelectCommand request, CancellationToken cancellationToken)
        {
            var quest = new Result() { Code = (int)CodeEnum.success };

            var list = culledRep.GetAll();

            quest.Code=(int)CodeEnum.success;
            quest.Data = list;

            return quest;
        }
    }
}
